xquery version "1.0";
declare variable $titre as xs:string external;
declare variable $tag_filtre1 as xs:string external;
declare variable $tag_filtre2 as xs:string external;
declare variable $tag_filtre3 as xs:string external;

<html>
<head>
	<link rel='stylesheet' media='screen' type='text/css' href='../design.css' />
</head>
<body>
<div class="droite_bas">
<h1>{$titre}</h1>
	{   
		for $f1 in distinct-values(doc("fic/citations.xml")//*[local-name() eq $tag_filtre1])
		return
		<ul class="{$f1}"><a id="txt_f1" name="{$f1}"></a><h3>{$f1}</h3>{
			for $f2 in distinct-values(doc("fic/citations.xml")//citation[*[local-name() eq $tag_filtre1]=$f1]/*[local-name() eq $tag_filtre2])
			return 
			<ul class="{$f2}"><a name="{$f2}"></a>{
				for $f3 in distinct-values(doc("fic/citations.xml")//citation[*[local-name() eq $tag_filtre1]=$f1 and *[local-name() eq $tag_filtre2]=$f2]/*[local-name() eq $tag_filtre3])
				let $cita := doc("fic/citations.xml")//citation[*[local-name() eq $tag_filtre1]=$f1 and *[local-name() eq $tag_filtre2]=$f2]/texte
				return(
					<p id="txt_f2">{$tag_filtre2} : {$f2}</p>,
					<li>
						<p id="txt_f3_comm"><b>{$tag_filtre3} : </b> {$f3} 
						<br/> <b>Citation : </b>{$cita}</p>
					</li>)
			}</ul> 
	   }</ul>
    }
</div>
</body>
</html>
